import React, {Component} from 'react';
const ipcRenderer = require('electron').ipcRenderer;
import {Row, Col} from 'antd';
class Progress extends Component {
    constructor() {
        super();
        this.state = {
            data: [],
            timer: null,
            visible: false
        };
    }

    componentDidMount() {
        ipcRenderer.on('onRecv_applfCommis', function (e, d) {
            let state = this.state;
            state.visible = true;
            state.data.push(d);
            this.setState(state);
            console.log(this.state.data);
        }.bind(this));
    }

    componentDidUpdate() {

    }

    componentWillReceiveProps() {
        if (this.props.start) {
            ipcRenderer.send('applfCommin', this.props.ad);
        } else {
            ipcRenderer.send('stopApplf');
        }
    }

    render() {
        return (
            <Row>
                <Col span={24} style={{border:'1px sold #CCCCCC',height:'400px'}}>
                    {this.state.data.map((item,index)=>{
                        return (<p key={index}>{item.name}</p>);
                    })}
                </Col>
            </Row>
        );
    }
}
Progress.propTypes = {
    start: React.PropTypes.bool.isRequired,
    ad: React.PropTypes.string,
};
Progress.start = false;
Progress.ad = '';
export default Progress;